let fs = require("fs")
let path = require("path")

module.exports = (req, res) => {
    let { findPath, filename } = req.query;

    if (!findPath.trim()) return res.send({ code: 400, msg: '未设置检索路径！' });
    if (!filename.trim()) return res.send({ code: 400, msg: '未设置文件名！' });

    let delVideoPath = path.resolve(findPath, filename);

    if (fs.existsSync(delVideoPath)) {
        fs.unlinkSync(delVideoPath);
        res.send({ code: 200, msg: `${filename} 删除成功！` });
    } else {
        res.send({ code: 400, msg: `${filename} 删除失败！` });
    }
}